///////////////////
/// mkII - Core ///
///////////////////

#pragma once

///////////////////
/// mkII - Core ///
///////////////////

#pragma once

namespace mk
{
namespace Core
{
namespace Math
{

MK_FORCEINLINE Vector128r const ModVector1
    (
    Vector128r const a,
    Vector128r const b 
    )
{
    Vector128r c = _mm_div_ss(a,b);
    // Get the lower whole number
    Vector128r i = _mm_cvttps_epi32(c); 
    Vector128r cTrunc = _mm_cvtepi32_ps(i);
    // Subtract the whole number from the left-hand side
    Vector128r base = _mm_mul_ss(cTrunc, b); 
    return _mm_sub_ss(a, base);
}

MK_FORCEINLINE Vector128r const ModVector4
(
    Vector128r const a,
    Vector128r const b 
)
{
    Vector128r c = _mm_div_ps(a,b);
    // Get the lower whole number
    Vector128r i = _mm_cvttps_epi32(c); 
    Vector128r cTrunc = _mm_cvtepi32_ps(i);
    // Subtract the whole number from the left-hand side
    Vector128r base = _mm_mul_ps(cTrunc, b); 
    return _mm_sub_ps(a, base);
}

MK_FORCEINLINE Vector128r const FloorVector1
(
    Vector128r const v
)
{
    return _mm_round_ps(v, _MM_FROUND_FLOOR);
}

MK_FORCEINLINE Vector128r const FloorVector4
(
    Vector128r const v
)
{
    return _mm_round_ps(v, _MM_FROUND_FLOOR);
}

MK_FORCEINLINE Vector128r const CeilVector1
(
    Vector128r const v
)
{
    return _mm_round_ps(v, _MM_FROUND_CEIL);
}

MK_FORCEINLINE Vector128r const CeilVector4
(
    Vector128r const v
)
{
    return _mm_round_ps(v, _MM_FROUND_CEIL);
}

MK_FORCEINLINE Vector128r const RoundVector1
(
    Vector128r const v
)
{
    return _mm_round_ps(v, _MM_FROUND_NINT);
}

MK_FORCEINLINE Vector128r const RoundVector4
(
    Vector128r const v
)
{
    return _mm_round_ps(v, _MM_FROUND_NINT);
}

} // namespace Math
} // namespace Core
} // namespace mk

